var app = getApp();
var utils=require('../../utils/util.js');
var aryIndex=0;//当前内容对应列表的索引值
var mapdata={
    "pageId":0,
    "centerLongitude":113.324520,//中心点经度
    "centerLatitude":23.099994,//中心点纬度
    "markers": [{
      iconPath: '../../images/point0.png',
      id: 0,
      latitude: 23.099994,
      longitude: 113.324520,
      title:"广州市软捷科技",
      width: 50,
      height: 60
    }],
    "points":[//列表对应的id跟经纬度
      {
          "id":1001,
          "longitude": 113.324500,
          "latitude": 23.099914
      },{
        "id":2001,
        "longitude": 113.324510,
         "latitude": 23.099944
    },{
        "id":3001,
        "longitude": 113.324530,
        "latitude": 23.099924
    },{
        "id":4001,
        "longitude": 113.324520,
        "latitude": 23.099964
    },{
        "id":5001,
        "longitude": 113.324520,
        "latitude": 23.099944
    },{
        "id":6001,
        "longitude": 113.324510,
        "latitude": 23.099964
    }
    ]
  };
Page({
  data:mapdata,  
  onLoad:function(e){
      var that=this;
          aryIndex=utils.findIndex(that.data.points,e.id);
        that.setData({
        "pageId":e.id,
        markers: [{
                iconPath: '../../images/point0.png',
                id: 0,
                latitude:that.data.points[aryIndex].latitude,
                longitude:that.data.points[aryIndex].longitude,
                title:"广州市软捷科技",
                width: 50,
                height:60
            }]
        });
  },
  markertap(e) {
    console.log(e.markerId)
  },
  openLocation:function(e){    
    var that=this;
    var lat=that.data.points[aryIndex].latitude;//23.099994;
    var lon=that.data.points[aryIndex].longitude;//113.324520;
    var openObj={};
        openObj.latitude=lat;
        openObj.longitude=lon;
        openObj.scale=18;
    console.log(openObj);
    wx.openLocation(openObj);
  }
  
})